package com.zzy.app.config.lifecycle;

import com.zzy.app.entity.lifecycle.Car;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Bean生命周期管理
 * 可以通过Bean注解标注initMethod、destroyMethod
 * 也可以通过实现 InitializingBean, DisposableBean接口
 *
 * 下面通过包扫描注入Cat implements InitializingBean, DisposableBean
 */
@ComponentScan("com.zzy.app.entity")
@Configuration
public class MainConfig7 {
    @Bean(initMethod = "init", destroyMethod = "destroy")
    public Car car() {
        return new Car();
    }

}
